#include<bits/stdc++.h>
using namespace std;
int n,r[100005],q[100005];
int main(){
 freopen("duel.in","r",stdin);
 freopen("duel.out","w",stdout);
 cin>>n;
 for(int i=1;i<=n;i++){
  cin>>r[i];
  q[r[i]]++;
 }
 int t=1,k=1;
 while(t<=n){
  if(q[t]!=0){
   r[k++]=t;
   q[t]--;
  }
  else t++;
 }
 k=1;
 for(int i=2;i<=n;i++)
  if(r[i]>r[k])k++;
 cout<<n-k+1;
 return 0;
}
